
//Reassessment
import excel using "dor_assessment_data_full.xlsx", ///
	sheet("Reassessment") firstrow clear
gen er = 1
label var er "Emergency Reassessment"
tempfile dor_er
save `dor_er'

//Technical assistance
import excel "dor_assessment_data_full.xlsx", ///
	sheet("Tech") firstrow clear
gen tech = 1
label var tech "Technical Assistance"
tempfile dor_tech
save `dor_tech'

//Untreated
import excel "dor_assessment_data_full.xlsx", ///
	sheet("Untreated") firstrow clear
gen untreated = 1
label var untreated "Untreated"
tempfile dor_untreated
save `dor_untreated'

* Append DTA files
use "`dor_er'", clear
append using "`dor_tech'"
append using "`dor_untreated'"

* Reshape DOR data from wide to long

rename County county

reshape long dor, i(county) j(year)

*---
* Cleaning

//Replace missing values for treatment dummies with zeros
foreach var of varlist er tech untreated {
	replace `var' = 0 if `var'==.
}

//Accommodate large numbers
format %14.0g dor

//Multilevel treatment variable
gen treat = 0
replace treat = 1 if tech==1
replace treat = 2 if er==1
label define treat 0 "Untreated" 1 "Tech Assist" 2 "Emergency Reassessment"
label values treat treat

//Labels
label var county "County Name"
label var year "Year"
label var dor "DOR County Assessment"
label var treat "Treatment Group"

//Add county fips code for merging
merge m:1 county using ky_countyname_fips
drop _merge
order fipsco

gen countyfip = "21"+fipsco
destring countyfip, force replace

* Save DTA file

save dor_assessment_data_full, replace
clear
